//
//  TicketCell.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/17.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "TicketCell.h"

@implementation TicketCell

- (void)awakeFromNib {
    self.ticketBgView.layer.cornerRadius = 3;
    self.ticketBgView.layer.masksToBounds= YES;
    
    [CommoneTools changeConstraintView:self.rightLine constraintHeight:0.45];
    [CommoneTools changeConstraintView:self.leftLine constraintHeight:0.45];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}


-(void)show:(CouponEntity *)couponEntity{
    
    self.descLabel.text = couponEntity.Description;
    self.validateTime.text = couponEntity.ExpirationDate;
    self.titleLabel.text = couponEntity.Title;
     self.priceLabel.attributedText = [self getPrice:couponEntity.Amount];
    
    if (couponEntity.Status == 1) {
     
        self.valiableImg.image = [UIImage imageNamed:@"bg_ticket_abled"];
        self.valiableLabel.text = @"可使用";
        
    }
    else if (couponEntity.Status == 2){
       
        self.valiableImg.image = [UIImage imageNamed:@"bg_ticket_disabled"];
        self.valiableLabel.text = @"已过期";

    }
    else{
     
        self.valiableImg.image = [UIImage imageNamed:@"bg_ticket_disabled"];
        self.valiableLabel.text = @"已使用";
        
    }
    
    
    
}


-(NSAttributedString *)getPrice:(NSDecimalNumber *)price {
    
    if (price == nil) {
        return nil;
    }
    NSMutableArray *mutableString = [[NSMutableArray alloc ] init];
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:price.stringValue hexColor:@"#ffffff" fontSize:@"33"]];
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:@"元"  hexColor:@"#ffffff" fontSize:@"20"]];
    return [CommoneTools getAttributeString:mutableString];
}


@end
